# 练习：https://ebank.xacbank.com/XAEIBankDemo/page/login/login.html?t=1679974008665
#
#  西安银行，密码123456，登录后
# 西安银行->转行汇款->行内批量转账
# 设置某个付款账户，不使用默认值
# 选择收款人，从里面选择赵云、马超
# 设置收款人的转账金额分别为1000、2000
# 点击下一步
# 点击提交

import time

from selenium import webdriver
from selenium.webdriver import ActionChains, Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

yh = webdriver.Edge()
yh.get("https://ebank.xacbank.com/XAEIBankDemo/page/login/login.html?t=1679974008665")
time.sleep(2)
yh.find_element(By.ID,"account").send_keys("123456")
yh.find_element(By.ID,"login").click()
time.sleep(2)
# 点X
a = yh.find_element("id","fw-gen-10009-dialog")
b = a.find_element("id","fw-gen-10009-closable").click()
time.sleep(2)
# 转账汇款
yh.find_element("class name","title_icon.icon-menu2").click()
time.sleep(2)
# 行内批量转账
yh.find_element(By.LINK_TEXT,"行内批量转账").click()
time.sleep(2)
# 切换到frame
yh.switch_to.frame(yh.find_element("id","fw-gen-10007-body"))
time.sleep(2)
# 付款账号下拉框
zh = yh.find_element("id","payAccount")
# 强转为select对象
s = Select(zh)
# 获取所有的下拉选项的对象
ls = s.options
lstext = []
for i in ls:
    lstext.append(i.text)
# 选中
s.select_by_visible_text(lstext[1])
time.sleep(2)
# # 选择收款人
yh.find_element("id","icon_find1").click()
time.sleep(2)
yh.switch_to.default_content()
# 切换frame
yh.switch_to.frame(yh.find_element("id","fw-gen-10011-iframe"))
time.sleep(2)
# 选择赵云，马超
yh.find_element(By.XPATH,'//*[@id="fw-gen-10001-tbody"]/tr[2]/td[1]/label').click()
time.sleep(2)
yh.find_element(By.XPATH,'//*[@id="fw-gen-10001-tbody"]/tr[3]/td[1]/label').click()
time.sleep(2)
yh.switch_to.parent_frame() # 退出上一层iframe
time.sleep(2)
# 点击确认
yh.find_element("class name","btn.btn-primary").click()
time.sleep(2)
# 输入金额
yh.switch_to.frame(yh.find_element("id","fw-gen-10007-body"))
time.sleep(2)
yh.find_element("xpath","//*[@id='tbody_1']/tr[1]/td[4]/input").send_keys("1000")
time.sleep(2)
yh.find_element("xpath","//*[@id='tbody_1']/tr[2]/td[4]/input").send_keys("2000")
time.sleep(2)
# 点击下一步
yh.find_element("id","next_btn").click()
time.sleep(2)
# 输入模版名称
yh.find_element("xpath","//*[@id='batchTempName']").send_keys("123456789")
time.sleep(2)
# 点击提交
yh.find_element("id","submit_btn").click()
time.sleep(2)
# 截图
timestr = time.strftime("%Y-%m-%d_%H-%M-%S",time.localtime())
yh.get_screenshot_as_file(f"d:\\yinhang{timestr}.png")
time.sleep(3)
yh.quit()
